import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace AiTrainingDatasetSamplesApi {
  /** 数据集数据信息 */
  export interface TrainingDatasetSamples {
    id: number; // 数据集数据id
    versionId?: number; // 数据集版本id
    rawContent?: string; // 数据集内容
    versionNum?: string; // 版本号
    isValid?: number; // 是否有效
    metadata: string; // 扩展字段
    splitType: string; // 划分类型:train-训练 eval-评估 test-测试 predict-预测
    qualityType: string; // 质量类型:excellent-极好, good-好, fair-及格, poor-差
    auditStatus: string; // 审核状态：pending-待审核, approved-通过, rejected-不通过
    auditNotes: string; // 审核备注
    datasetId?: number; // 数据集id
    qualityScore: number; // 质量评分0-5
    source: string; // 数据来源，如：manual/auto/imported
    auditType: string; // 审核类型：llm-模型标注，manual-人工标准
    previousId: number; // 上个版本id
  }
}

/** 查询数据集数据分页 */
export function getTrainingDatasetSamplesPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<AiTrainingDatasetSamplesApi.TrainingDatasetSamples>
  >('/ai/training-dataset-samples/page', data, { desensitize, encrypt });
}

/** 查询数据集数据详情 */
export function getTrainingDatasetSamples(id: number) {
  return requestClient.get<AiTrainingDatasetSamplesApi.TrainingDatasetSamples>(
    `/ai/training-dataset-samples/get?id=${id}`,
  );
}

/** 新增数据集数据 */
export function createTrainingDatasetSamples(
  data: AiTrainingDatasetSamplesApi.TrainingDatasetSamples,
) {
  return requestClient.post('/ai/training-dataset-samples/create', data);
}

/** 修改数据集数据 */
export function updateTrainingDatasetSamples(
  data: AiTrainingDatasetSamplesApi.TrainingDatasetSamples,
) {
  return requestClient.put('/ai/training-dataset-samples/update', data);
}

/** 删除数据集数据 */
export function deleteTrainingDatasetSamples(id: number) {
  return requestClient.delete(`/ai/training-dataset-samples/delete?id=${id}`);
}

/** 批量删除数据集数据 */
export function deleteTrainingDatasetSamplesList(ids: number[]) {
  return requestClient.delete(
    `/ai/training-dataset-samples/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出数据集数据 */
export function exportTrainingDatasetSamples(params: any) {
  return requestClient.download('/ai/training-dataset-samples/export-excel', {
    params,
  });
}
/** 下载数据集数据导入模板 */
export function importTrainingDatasetSamplesTemplate(dataFormat: string) {
  return requestClient.download(
    `/ai/training-dataset-samples/get-import-template?dataFormat=${dataFormat}`,
  );
}
/** 导入样本集 */
export function importTrainingDatasetSamples(data: any) {
  return requestClient.upload('/ai/training-dataset-samples/import', data);
}
